const passwords = {
  admin: '123456',
  store: '123456'
};

const userList = [
  {
    username: 'admin',
    role: 'ADMIN'
  },
  {
    username: 'store',
    role: 'STORE'
  }
];

export const login = (params): Promise<any> => {
  return new Promise<any>((resolve, reject) => {
    setTimeout(() => {
      let user = userList.find((v) => v.username === params.account);
      if (!user) {
        return reject();
      }
      if (passwords[user.username] && passwords[user.username] !== params.password) {
        return reject();
      }
      resolve({
        data: user
      });
    }, 500);
  });
};
